/**
 * author      : dormi330
 * date        : 2018/6/26
 * project     : mybatis
 * description : 订单item
 * TODO 修改成 SkuSnapshot sku快照
 */

package com.deep.trade.domain.order;

import com.deep.trade.common.BaseEntity;

import java.math.BigDecimal;

public class TradeOrderSku extends BaseEntity {
    private String tradeOrderId;            // 交易订单id

    private String sellerId;                // 卖家
    private String sellerName;              // 卖家名称
    private String shopId;                  // 商铺信息
    private String itemId;                  // item信息
    private String itemName;                // 此item的名称
    private String skuId;                   // sku id
    private String skuCode;                 // sku id
    private String imgUrl;                  // 图片地址
    private String brandId;                 // 品牌id
    private int quantity;                   // 购买数量

    // 金额相关的信息
    private BigDecimal priceMoney;         // sku价格
    private BigDecimal discountMoney;      // sku级优惠额度
    private BigDecimal freightMoney;       // 运费金额
    private BigDecimal itemMoney;           // 订单所有商品的商品金额小计 ,运算得来
    private BigDecimal payMoney;            // 实付金额, 运算得来

    /**
     * - 计算商品金额小计
     * - 计算实际价格
     */
    public void calculateMoney() {
        // 商品总额 = 单价 * 数量
        this.itemMoney = this.priceMoney.multiply(new BigDecimal(this.quantity));

        // 实付 = 商品总额 + 运费 - 折扣
        this.payMoney = this.itemMoney.add(this.freightMoney).subtract(this.discountMoney);

        // 如果小于0, 则置为0
        this.payMoney = this.payMoney.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : this.payMoney;
    }

    public TradeOrderSku() {
        super();
    }

// === setter / getter ===

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public String getSellerName() {
        return sellerName;
    }

    public void setSellerName(String sellerName) {
        this.sellerName = sellerName;
    }

    public BigDecimal getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(BigDecimal payMoney) {
        this.payMoney = payMoney;
    }

    public BigDecimal getDiscountMoney() {
        return discountMoney;
    }

    public void setDiscountMoney(BigDecimal discountMoney) {
        this.discountMoney = discountMoney;
    }

    public BigDecimal getFreightMoney() {
        return freightMoney;
    }

    public void setFreightMoney(BigDecimal freightMoney) {
        this.freightMoney = freightMoney;
    }

    public BigDecimal getItemMoney() {
        return itemMoney;
    }

    public void setItemMoney(BigDecimal itemMoney) {
        this.itemMoney = itemMoney;
    }

    public String getTradeOrderId() {
        return tradeOrderId;
    }

    public void setTradeOrderId(String tradeOrderId) {
        this.tradeOrderId = tradeOrderId;
    }

    public String getSellerId() {
        return sellerId;
    }

    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getSkuId() {
        return skuId;
    }

    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public BigDecimal getPriceMoney() {
        return priceMoney;
    }

    public void setPriceMoney(BigDecimal priceMoney) {
        this.priceMoney = priceMoney;
    }

    public String getBrandId() {
        return brandId;
    }

    public void setBrandId(String brandId) {
        this.brandId = brandId;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getSkuCode() {
        return skuCode;
    }

    public void setSkuCode(String skuCode) {
        this.skuCode = skuCode;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }
}
